#include "stm32f4xx.h"                  
#include "iwdg.h"
 
//prer：预分频值
//rlr：自动重装载值
void IWDG_Init(unsigned char prer,unsigned int rlr)//IWDG初始化
{
	IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);//取消写保护，方便后续调用寄存器
	IWDG_SetPrescaler(prer);//设置预分频值
	IWDG_SetReload(rlr);//设置重装载值
	IWDG_ReloadCounter();//把重装载寄存器rlr的值加载到KR寄存器中，进行看门狗喂狗
	IWDG_Enable();//看门狗使能
}
 
void IWDG_FEED(void)//看门狗喂狗
{
	IWDG_ReloadCounter();//往KR寄存器中写0xAAAA；
}
